package com.qifan.energy.adapter;

import android.view.ViewGroup;
import android.widget.ImageView;

import com.qifan.energy.adapter.viewholder.ImageHolder;
import com.qifan.energy.R;
import com.qifan.energy.global.GlideApp;
import com.youth.banner.adapter.BannerAdapter;
import com.youth.banner.util.BannerUtils;

import java.util.List;

/**
 * 自定义布局，网络图片
 */
public class ImageNetAdapter2 extends BannerAdapter<String, ImageHolder> {

    public ImageNetAdapter2(List<String> mDatas) {
        super(mDatas);
    }

    @Override
    public ImageHolder onCreateHolder(ViewGroup parent, int viewType) {
        ImageView imageView = (ImageView) BannerUtils.getView(parent, R.layout.home_banner_item);
        //通过裁剪实现圆角
        /*if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            BannerUtils.setBannerRound(imageView,20);
        }*/
        return new ImageHolder(imageView);
    }

    @Override
    public void onBindView(ImageHolder holder, String data, int position, int size) {
        //通过图片加载器实现圆角，你也可以自己使用圆角的imageview，实现圆角的方法很多，自己尝试哈
        GlideApp.with(holder.itemView)
                .load(data)
                .into(holder.imageView);
                /*.apply(RequestOptions.bitmapTransform(new RoundedCorners(30)))*/
    }
}
